//
//  environment.h
//  cobalt
//
//  Created by Nicolas Godbout on 2013-08-28.
//  Copyright (c) 2013 Nicolas Godbout. All rights reserved.
//

#ifndef __cobalt__environment__
#define __cobalt__environment__

#include <cstdint>
#include <map>
#include <string>

#include "node.h"
#include "triple.h"
#include "graph.h"

namespace rdf {

    class Environment {
    public:
        Environment() noexcept;
        
        // const char version
        // Environment class assumes ownership of any
        RDFNode const& createBlankNode() noexcept;
        RDFNode const& createBlankNode(char const*) noexcept;
        RDFNode const& createNamedNode(char const*) noexcept;
        RDFNode const& createLiteral(char const*, NamedNode const&) noexcept;
        RDFNode const& createLiteral(char const*, char const*) noexcept;
        
        Triple  createTriple(const RDFNode& subject, const RDFNode& predicate, const RDFNode& object) noexcept;
        Graph   createGraph(Graph::TripleList triples) noexcept;
        
        
        // std::string version
//        RDFNode createBlankNode(const std::string& ident) noexcept;
        RDFNode const& createNamedNode(const std::string& value) noexcept;
        RDFNode const& createLiteral(const std::string& value) noexcept;
        RDFNode const& createLiteral(const std::string& value, const std::string& lang) noexcept;
        RDFNode const& createLiteral(const std::string& value, const NamedNode& datatype) noexcept;
        

    private:
        uint64_t    blankNodeCounter;
        
        typedef std::set<BlankNode>             indexBlank_t;
        typedef std::set<NamedNode>             indexNamed_t;
        typedef std::set<Literal>               indexLiteral_t;
        
        indexBlank_t    indexBlank;
        indexNamed_t    indexNamed;
        indexLiteral_t  indexLiteral;
    };
    
    inline
    Environment::Environment() noexcept
    : blankNodeCounter(0) {}
    
} // namespace rdf

#endif /* defined(__cobalt__environment__) */
